#!/bin/bash

# 修改 bash 的 PS1 符号

#历年新年日期字典 21世纪100年
declare -A years
years=(
 [2001]="-01-24" [2002]="-02-12" [2003]="-02-01" [2004]="-01-22" [2005]="-02-09"
 [2006]="-01-29" [2007]="-02-18" [2008]="-02-07" [2009]="-01-26" [2010]="-02-14"
 [2011]="-02-03" [2012]="-01-23" [2013]="-02-10" [2014]="-01-31" [2015]="-02-19"
 [2016]="-02-08" [2017]="-01-28" [2018]="-02-16" [2019]="-02-05" [2020]="-01-25"
 [2021]="-02-12" [2022]="-02-01" [2023]="-01-22" [2024]="-02-10" [2025]="-01-29"
 [2026]="-02-17" [2027]="-02-06" [2028]="-01-26" [2029]="-02-13" [2030]="-02-03"
 [2031]="-01-23" [2032]="-02-11" [2033]="-01-31" [2034]="-02-19" [2035]="-02-08"
 [2036]="-01-28" [2037]="-02-15" [2038]="-02-04" [2039]="-01-24" [2040]="-02-12"
 [2041]="-02-01" [2042]="-01-22" [2043]="-02-10" [2044]="-01-30" [2045]="-02-17"
 [2046]="-02-06" [2047]="-01-26" [2048]="-02-14" [2049]="-02-02" [2050]="-01-23"
 [2051]="-02-11" [2052]="-02-01" [2053]="-02-19" [2054]="-02-08" [2055]="-01-28"
 [2056]="-02-15" [2057]="-02-04" [2058]="-01-24" [2059]="-02-12" [2060]="-02-02"
 [2061]="-01-21" [2062]="-02-09" [2063]="-01-29" [2064]="-02-17" [2065]="-02-05"
 [2066]="-01-26" [2067]="-02-14" [2068]="-02-03" [2069]="-01-23" [2070]="-02-11"
 [2071]="-01-31" [2072]="-02-19" [2073]="-02-07" [2074]="-01-27" [2075]="-02-15"
 [2076]="-02-05" [2077]="-01-24" [2078]="-02-12" [2079]="-02-02" [2080]="-01-22"
 [2081]="-02-09" [2082]="-01-29" [2083]="-02-17" [2084]="-02-06" [2085]="-01-26"
 [2086]="-02-14" [2087]="-02-03" [2088]="-01-24" [2089]="-02-10" [2090]="-01-30"
 [2091]="-02-18" [2092]="-02-07" [2093]="-01-27" [2094]="-02-15" [2095]="-02-05"
 [2096]="-01-25" [2097]="-02-12" [2098]="-02-01" [2099]="-01-21" [2100]="-02-09"
)

#生肖吉祥物
SXAnimals=(🐁 🐄 🐅 🐇 🐉 🐍 🐴 🐏 🐒 🐔 🐕 🐖)

#当前年份
year=`date +%Y`

#当前年份对应的新年日期
newYear="${year}${years[${year}]}"

#当前时间戳和本年度新年时间戳
tmstmp_now=`date +%s`
tmstmp_newYear=`date -d ${newYear} +%s`

if [ $tmstmp_now -gt $tmstmp_newYear ]; then #新的一年开始了
    #本年对应的生肖下标(从0开始)，2020恰好为鼠年(0)
    idx=$(( (${year} - 2020) % 12 ))
    animal=${SXAnimals[${idx}]}
    #echo $animal
    sed -i "69s/] .  /] ${animal}  /g" ~/.bashrc
    source ~/.bashrc
fi
